package com.white.androidstudy.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;

/**
 * Created by ytf on 2017/12/5 005.
 * Description:
 */

public class VV extends AbsView
{
    Paint pt;

    public VV(Context context)
    {
        super(context);
        init();
    }

    public VV(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        init();
    }

    private void init()
    {
        pt = new Paint(Paint.ANTI_ALIAS_FLAG);
        pt.setStyle(Paint.Style.FILL);
        pt.setColor(Color.RED);
    }

    @Override
    public int getDefaultWrapWidth()
    {
        return 100;
    }

    @Override
    public int getDefaultWrapHeight()
    {
        return 100;
    }

    private static final int LAYER_FLAGS =
            Canvas.MATRIX_SAVE_FLAG
                    | Canvas.CLIP_SAVE_FLAG
                    | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
                    | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
                    | Canvas.CLIP_TO_LAYER_SAVE_FLAG;

    @Override
    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);
        canvas.drawCircle(150, 150, 100, pt);
        canvas.saveLayerAlpha(0, 0, 400, 400, 127, LAYER_FLAGS);
        pt.setColor(Color.BLUE);
        canvas.drawCircle(200, 200, 100, pt);
        canvas.restore();

    }

    @Override
    public void onGlobalLayout()
    {

    }
}
